<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title> 管理中心 -</title>
    <meta name="robots" content="noindex, nofollow" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" type="text/css" href="js/jquery/uploadify/uploadify.css"/>
    <link href="styles/general.css" rel="stylesheet" type="text/css" /><link href="styles/main.css" rel="stylesheet" type="text/css" />
     <script type="text/javascript" src="js/jquery/uploadify/jquery.min.js"></script>
     <script src="js/jquery/uploadify/jquery.uploadify.js" type="text/javascript"></script>
    <script src="js/utils.js" type="text/javascript"></script>
    
    
    <link rel="stylesheet" type="text/css" href="http://ajax.pupkk.com/dojo/1.7.5/dojo/resources/dojo.css" />
	<link rel="stylesheet" type="text/css" href="http://ajax.pupkk.com/dojo/1.7.5/dijit/themes/tundra/tundra.css" />
	<script src="http://ajax.pupkk.com/dojo/1.7.5/dojo/dojo.js" djConfig="parseOnLoad:true"></script>
	
    <script type="text/javascript">
	dojo.require("dojo.parser");
	dojo.require("dijit.form.DateTextBox");
	dojo.require("dijit.form.FilteringSelect");
	function validate()
	{
		return formvalidator("all");
	}
	function formvalidator(obj)
	{
		var controlId = "all";
		 if (typeof(obj) != "string" )
		 {
			 controlId = obj.id;
		 }
		if(controlId=="all" || controlId=="model.appname")
		{
			if(Utils.trim(document.getElementById("model.appname").value)=="")
			{
				document.getElementById("CompareValidator1").style.visibility="visible";
				return false;
			}
			else
			{
				document.getElementById("CompareValidator1").style.visibility="hidden";
			}
		}
		if(controlId=="all" || controlId=="model.cpid")
		{
			if(Utils.trim(dijit.byId("model.cpid").get('value'))=="-1")
			{
				document.getElementById("CompareValidator2").style.visibility="visible";
				return false;
			}
			else
			{
				document.getElementById("CompareValidator2").style.visibility="hidden";
			}
		}
		if(controlId=="all" || controlId=="model.categoryparentid")
		{
			if(Utils.trim(document.getElementById("model.categoryparentid").value)=="-1")
			{
				document.getElementById("CompareValidator3").style.visibility="visible";
				return false;
			}
			else
			{
				document.getElementById("CompareValidator3").style.visibility="hidden";
			}
		}
		if(controlId=="all" || controlId=="model.apppackage")
		{
			if(Utils.trim(document.getElementById("model.apppackage").value)=="")
			{
				document.getElementById("CompareValidator4").style.visibility="visible";
				return false;
			}
			else
			{
				document.getElementById("CompareValidator4").style.visibility="hidden";
			}
		}
		return true;
	}
	</script>
</head>
<body>
    <form  id="theForm"  method="post" name="theForm" onsubmit="return validate();" action="app_save.do?type=<s:property value="type"/>">
    <input name="cpid" type="hidden" id="cpid"  value="<s:property value="cpid"/>"/>
    <input name="categoryparentid" type="hidden" id="categoryparentid"  value="<s:property value="categoryparentid"/>"/>
    <input name="appName" type="hidden" id="appName"  value="<s:property value="appName"/>"/>
    <h1>
        <span class="action-span"><a href="app_list.do?type=insert&cpid=<s:property value="cpid"/>&categoryparentid=<s:property value="categoryparentid"/>&appName=<s:property value="appName"/>">游戏列表</a></span> <span
            class="action-span1"><a href="mainframe.jsp">
                首页</a> </span><span id="search_id" class="action-span1">- 游戏管理 </span>
    </h1>
    <!-- start goods form -->
    <div class="tab-div">
        <!-- tab bar -->
        <div id="tabbar-div">
            <p>
                <span class="tab-front" id="general-tab">游戏信息</span>
                <span class="tab-front"><a href="app_show1.do?type=app&model.appnumber=<s:property value="model.appnumber" />">物料下载</a></span>
            </p>
        </div>
        <!-- tab body -->
        <div id="tabbody-div">
            <!-- 通用信息 -->
             <input type="hidden" name="model.createuser" id="model.createuser" value="<s:property value="model.createuser"/>"/>
             <input type="hidden" name="model.createdate" id="model.createdate" value="<s:property value="model.createdate"/>"/>
             <input type="hidden" name="model.appstatus" id="model.appstatus" value="<s:property value="model.appstatus"/>"/>
             <input type="hidden" name="model.appnumber" id="model.appnumber" value="<s:property value="model.appnumber"/>" />	
            <input type="hidden" name="model.cpid" value="1003" />
            <s:if test='"wl".equals(msg)'>
            <s:set name="tmp_apk" value="false" /><s:set name="tmp_icon" value="false" /><s:set name="tmp_remark" value="false" /><s:set name="tmp_screenshot" value="false" /><s:set name="tmp_other" value="false" />
			<s:iterator value="aslist" status="i">
				<s:if test='"0".equals(type)'>
			  		<s:set name="tmp_icon" value="true" />
			 	</s:if>
			  	<s:if test='"1".equals(type)'>
			  		<s:set name="tmp_remark" value="true" />
			  	</s:if>
			  	<s:if test='"2".equals(type)'>
			  		<s:set name="tmp_screenshot" value="true" />
			  	</s:if>
			  	<s:if test='"3".equals(type)'>
			  		<s:set name="tmp_other" value="true" />
			  	</s:if>
			  	<s:if test='"4".equals(type)'>
			  		<s:set name="tmp_apk" value="true" />
			  	</s:if>
			  </s:iterator>
            	<table  width="90%" id="general-table" align="center">
            		<tbody>
            		<tr>
                        <td style="vertical-align: top;" class="label2">游戏apk： </td>
                        <td>
                        <s:if test="isUpdate.equals('true')">
                        	<form>
								<div id="queue"></div>
								<input id="appfile" name="appfile" type="file"/>
							</form>
							<script type="text/javascript">
								$(function() {
									$('#appfile').uploadify({
										'formData'     : {
											'timestamp' : '321',
											'model.appnumber':'<s:property value="model.appnumber"/>'
										},
										'swf'      : 'js/jquery/uploadify/uploadify.swf',
										'uploader' : 'app_uploadapp.do',
										'buttonText' : '上传游戏...',
										'fileTypeDesc' : 'Apk Files',
								        'fileTypeExts' : '*.apk',
								        'successTimeout': 3000,
										'onUploadSuccess' : function(file, data, response) {
											if(data.indexOf("package")!=-1){
												alert("请检查包名是否正确！！");
											}else{
												var div = document.getElementById("appsdiv");
												var divv = div.innerHTML;
												if(divv.indexOf("无")!=-1){
													div.innerHTML = data;
												}else{
													div.innerHTML = divv+"&nbsp;"+data;
												}
											}
									    }
									    ,
									    'cancel':'false'
									});
								});
							</script>
							</s:if>
                        </td>
                    </tr>
                    <tr>
                    	<td class="label2"></td>
                    	<td>
                    		<div id="appsdiv">
							 <s:if test="tmp_apk">
							 <s:iterator  value="aslist" status="i">
                        		<s:if test='"4".equals(type)'>
                        			<div class="imgDiv<s:property value="id"/>" onmouseover="imgdivon('deleteimg<s:property value="id"/>','0')" onmouseout="imgdivon('deleteimg<s:property value="id"/>','1')" style="display : inline-block;position : relative;">
							    		<a id="<s:property value="id"/>" target="_blank" href="app_downscreenshot.do?appscreenshotid=<s:property value="id" />" ><s:property value="imgname" /></a>
							    		<a href="javascript:void(0);" onclick="deleteappscreenshot('<s:property value="id"/>')">
											<img id="deleteimg<s:property value="id"/>" src="images/xxxxx.PNG" class="delete" style="position : absolute;top : 0px;right : 0px;width : 15px;height : 15px;display:none;"/>
							    		</a>
									</div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								</s:if>
                        		</s:iterator>
                        		</s:if>
                        		<s:else>无</s:else>
                            </div>
                    	</td>
                    </tr>
                    <tr>
                        <td style="vertical-align: top;" class="label2">游戏图标： </td>
                        <td>
                        <s:if test="isUpdate.equals('true')">
                        	<form>
								<div id="queue"></div>
								<input id="iconfile" name="iconfile" type="file"/>
							</form>
							<script type="text/javascript">
								$(function() {
									$('#iconfile').uploadify({
										'formData'     : {
											'timestamp' : '321',
											'model.appnumber':'<s:property value="model.appnumber"/>'
										},
										'swf'      : 'js/jquery/uploadify/uploadify.swf',
										'uploader' : 'app_uploadicon.do',
										'buttonText' : '上传图标...',
										'fileTypeDesc' : 'Image Files',
								        'fileTypeExts' : '*.gif; *.jpg; *.png',
								        'successTimeout': 3000,
										'onUploadSuccess' : function(file, data, response) {
											var div = document.getElementById("appicondiv");
											var divv = div.innerHTML;
											if(divv.indexOf("无")!=-1){
												div.innerHTML = data;
											}else{
												div.innerHTML = divv+"&nbsp;"+data;
											}
									    }
									    ,
									    'cancel':'false'
									});
								});
							</script>
							</s:if>
                        </td>
                    </tr>
                    <tr>
                    	<td class="label2"></td>
                    	<td>
                    		<div id="appicondiv">
							 <s:if test="tmp_icon">
							 	<s:iterator  value="aslist" status="i">
                        		<s:if test='"0".equals(type)'>
                        			<div class="imgDiv<s:property value="id"/>" onmouseover="imgdivon('deleteimg<s:property value="id"/>','0')" onmouseout="imgdivon('deleteimg<s:property value="id"/>','1')" style="display : inline-block;position : relative;">
										<img style="width:100px;heigth:100px" id="<s:property value="id"/>" src="app_d.do?appscreenshoturl=icon/<s:property value="imgrename"/>"/>
							    		<a href="javascript:void(0);" onclick="deleteappscreenshot('<s:property value="id"/>')">
											<img id="deleteimg<s:property value="id"/>" src="images/xxxxx.PNG" class="delete" style="position : absolute;top : 0px;right : 0px;width : 20px;height : 20px;display:none;"/>
							    		</a>
							    		<div id="filename<s:property value="id"/>" style="clear:both;text-align:center;margin: 3px 0px 3px 0px"><a title="点击下载" href="app_downscreenshot.do?appscreenshotid=<s:property value="id" />" target="_blank"><s:property value="imgname" /></a></div>
									</div>
								</s:if>
                        		</s:iterator>
                        		</s:if><s:else>无</s:else>
                            </div>
                    	</td>
                    </tr>
                    <tr>
                        <td style="vertical-align: top;" class="label2">游戏描述： </td>
                        <td>
                        <s:if test="isUpdate.equals('true')">
                        	<form>
								<div id="queue"></div>
								<input id="remarkfile" name="remarkfile" type="file"/>
							</form>
							<script type="text/javascript">
								$(function() {
									$('#remarkfile').uploadify({
										'formData'     : {
											'timestamp' : '321',
											'model.appnumber':'<s:property value="model.appnumber"/>'
										},
										'swf'      : 'js/jquery/uploadify/uploadify.swf',
										'uploader' : 'app_uploadremark.do',
										'buttonText' : '上传描述...',
										'fileTypeDesc' : 'Text Files',
								        'fileTypeExts' : '*.txt',
								        'successTimeout': 3000,
										'onUploadSuccess' : function(file, data, response) {
											var div = document.getElementById("appremarkdiv");
											var divv = div.innerHTML;
											if(divv.indexOf("无")!=-1){
												div.innerHTML = data;
											}else{
												div.innerHTML = divv+"&nbsp;"+data;
											}
									    }
									    ,
									    'cancel':'false'
									});
								});
							</script>
							</s:if>
							 <div id="appremarkdiv">
							 <s:if test="tmp_remark">
							 	<s:iterator  value="aslist" status="i">
                        		<s:if test='"1".equals(type)'>
                        			<div class="imgDiv<s:property value="id"/>" onmouseover="imgdivon('deleteimg<s:property value="id"/>','0')" onmouseout="imgdivon('deleteimg<s:property value="id"/>','1')" style="display : inline-block;position : relative;">
							    		<a id="<s:property value="id"/>" target="_blank" href="app_d.do?model.refilename=remark.txt&appscreenshoturl=remark/<s:property value="imgrename"/>" ><s:property value="imgname" /></a>
							    		<a href="javascript:void(0);" onclick="deleteappscreenshot('<s:property value="id"/>')">
											<img id="deleteimg<s:property value="id"/>" src="images/xxxxx.PNG" class="delete" style="position : absolute;top : 0px;right : 0px;width : 15px;height : 15px;display:none;"/>
							    		</a>
									</div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								</s:if>
                        		</s:iterator>
                        		</s:if><s:else>无</s:else>
                            </div>
                            <br />
                        </td>
                    </tr>
                    <tr>
                        <td style="vertical-align: top;" class="label2">游戏截图： </td>
                        <td>
                        <s:if test="isUpdate.equals('true')">
                            <form>
								<div id="queue"></div>
								<input id="filescreenshot" name="filescreenshot" type="file"/>
							</form>
						
							<script type="text/javascript">
								$(function() {
									$('#filescreenshot').uploadify({
										'formData'     : {
											'timestamp' : '321',
											'model.appnumber':'<s:property value="model.appnumber"/>'
										},
										'swf'      : 'js/jquery/uploadify/uploadify.swf',
										'uploader' : 'app_uploadscreenshot.do',
										'buttonText' : '添加截图...',
										'fileTypeDesc' : 'Image Files',
								        'fileTypeExts' : '*.gif; *.jpg; *.png',
								        'successTimeout': 3000,
										'onUploadSuccess' : function(file, data, response) {
											var div = document.getElementById("filescreenshotdiv");
									        div.innerHTML = data;
									        reload();
									    }
									    ,
									    'cancel':'false'
									});
								});
							</script>
							</s:if>
                        </td>
                    </tr>
                    <tr>
                        <td style="vertical-align: top;text-align: right;" class="label2"></td>
                        <td>
                        	<div style="float: left;" id="filescreenshotdiv">
                        	<s:if test='aslist.size()>0'><jsp:include page="_uploadscreenshot.jsp" /></s:if><s:else>无</s:else>
                        	</div>
                        </td>
                    </tr>
                    <tr>
                        <td style="vertical-align: top;" class="label2">其他： </td>
                        <td>
                        <s:if test="isUpdate.equals('true')">
                        	<form>
								<div id="queue"></div>
								<input id="remark1file" name="remarkfile" type="file"/>
							</form>
							<script type="text/javascript">
								$(function() {
									$('#remark1file').uploadify({
										'formData'     : {
											'timestamp' : '321',
											'model.appnumber':'<s:property value="model.appnumber"/>'
										},
										'swf'      : 'js/jquery/uploadify/uploadify.swf',
										'uploader' : 'app_uploadremark1.do',
										'buttonText' : '其他...',
								        'successTimeout': 3000,
										'onUploadSuccess' : function(file, data, response) {
											var div = document.getElementById("appremark1div");
											var divv = div.innerHTML;
											if(divv.indexOf("无")!=-1){
												div.innerHTML = data;
											}else{
												div.innerHTML = divv+"&nbsp;"+data;
											}
									    }
									    ,
									    'cancel':'false'
									});
								});
							</script>
							</s:if>
							 <div id="appremark1div">
							 <s:if test="tmp_other">
							 	<s:iterator  value="aslist" status="i">
                        		<s:if test='"3".equals(type)'>
                        			<div class="imgDiv<s:property value="id"/>" onmouseover="imgdivon('deleteimg<s:property value="id"/>','0')" onmouseout="imgdivon('deleteimg<s:property value="id"/>','1')" style="display : inline-block;position : relative;">
							    		<a id="<s:property value="id"/>" target="_blank" href="app_d.do?model.refilename=<s:property value="imgname" />&appscreenshoturl=remark1/<s:property value="imgrename"/>" ><s:property value="imgname" /></a>
							    		<a href="javascript:void(0);" onclick="deleteappscreenshot('<s:property value="id"/>')">
											<img id="deleteimg<s:property value="id"/>" src="images/xxxxx.PNG" class="delete" style="position : absolute;top : 0px;right : 0px;width : 15px;height : 15px;display:none;"/>
							    		</a>
									</div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								</s:if>
                        		</s:iterator>
                        		</s:if><s:else>无</s:else>
                            </div>
                            <br />
                        </td>
                    </tr>
            		</tbody>
            	</table>
            	<input type="hidden" name="model.appname" value="<s:property value="model.appname" />" />
            	<input type="hidden" name="model.categoryid" value="<s:property value="model.categoryid" />" />
            	<input type="hidden" name="model.apppackage" value="<s:property value="model.apppackage" />" />
            	<input type="hidden" name="model.appversion" value="<s:property value="model.appversion" />" />
            	<input type="hidden" name="model.appentry" value="<s:property value="model.appentry" />" />
            </s:if>
            <s:if test='!"wl".equals(msg)'>
            <table width="90%" id="general-table" align="center">
                <tbody>
                    <tr>
                        <td class="label2">游戏名称：</td>
                        <td>
                            <input type="text" name="model.appname" id="model.appname" value="<s:property value="model.appname"/>" style="float: left;
                                " size="30" />
                            <span class="require-field">*</span>&nbsp;
                        <span id="CompareValidator1" style="color:Red;visibility:hidden;">不能为空</span>
                        </td>
                    </tr>
                    <tr>
                        <td class="label2">类别：</td>
                        <td><div id="categoryiddiv">
				             <select id="model.categoryid" name="model.categoryid">
					               <option value="-1">--请选择--</option>
					               <s:iterator value="caplist" status="stat">
						               	<option value="<s:property value="id" />" <s:if test="id.equals(model.categoryid)">selected</s:if>><s:property value="categoryName" /></option>
						            </s:iterator>
					             </select><span id="CompareValidator3" style="color:Red;visibility:hidden;">不能为空</span>
				             </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="label2">包名：</td>
                        <td>
                            <input type="text" name="model.apppackage" id="model.apppackage" value="<s:property value="model.apppackage"/>" style="float: left;
                                " size="30" />
                            <span class="require-field">*</span><span id="CompareValidator4" style="color:Red;visibility:hidden;">不能为空</span>
                        </td>
                    </tr>
                    <tr>
                        <td class="label2">版本：</td>
                        <td>
                            <input type="text" name="model.appversion" id="model.appversion" value="<s:property value="model.appversion"/>" style="float: left;
                                " size="30" />
                        </td>
                    </tr>
                    <s:if test="isUpdate.equals('true')">
                    <tr>
                    	<td class="label2" colspan="2">
				            <div class="button-div">
				                <input type="submit" value=" 确定 " class="button" />
				                <input type="reset" value=" 重置 " class="button" />
				            </div>
                    	</td>
                    </tr>
                    </s:if>
                </tbody>
            </table>
            <input type="hidden" name="model.appentry" id="model.appentry" value="<s:property value="model.appentry"/>" />
            <input type="hidden" id="model.appiconname" name="model.appiconname" value="<s:property value="model.appiconname"/>"/>
            <input type="hidden" id="model.reiconname" name="model.reiconname" value="<s:property value="model.reiconname"/>"/>
            <input type="hidden" id="model.appiconsrc" name="model.appiconsrc" value="<s:property value="model.appiconsrc"/>"/>
            <input type="hidden" name="model.appremark" value="<s:property value="model.appremark"/>"/>
            <input type="hidden" id="model.appfilename" name="model.appfilename" value="<s:property value="model.appfilename"/>"/>
            <input type="hidden" id="model.refilename" name="model.refilename" value="<s:property value="model.refilename"/>"/>
            <input type="hidden" id="model.appfilesrc" name="model.appfilesrc" value="<s:property value="model.appfilesrc"/>"/>
            </s:if>
            <!-- 通用信息end -->
        </div>
    </div>
    <!-- end goods form -->
    </form>
    <script type="text/javascript" src="js/tab.js"></script>
    <script type="text/javascript" src="js/validator.js"></script>
<script type="text/javascript">
function imgdivon(deleteimgid,type)
{
    if(type==0)
    {
		document.getElementById(deleteimgid).style.display="";  
    }
    if(type==1)
    {
    	document.getElementById(deleteimgid).style.display="none";  
    }
}
function deleteappscreenshot(id)
{
    
    if (confirm("确定删除？"))
    {
       $.get("app_deletescreenshot.do?appscreenshotid="+id, 
       function(data) 
       { 
          if(data.indexOf('ok')>-1)
          {
        	  document.getElementById(id).parentNode.removeChild(document.getElementById(id));
          }
          
       });
    }
}
    function channegcategory(c)
    {
        if(c.value!='')
        {
        	$.get("app_channegcategory.do?model.categoryparentid="+c.value, 
        	           function(data) 
        	           { 
        	            	  document.getElementById("categoryiddiv").innerHTML=data;
        	           });
        }
    }
    function reload(){
    	 jQuery().prepare_slider(); 
		jQuery('#slider_list > li').over();
		//=======intro================
		var slider_link = jQuery('#right_but');
		var slider_link_index = 1;
		var slider_count = jQuery('#slider_list > li').size();	

		function slider_intro(){
			if(slider_link_index <= slider_count){
				slider_link.trigger('click');
				slider_link_index++;
				setTimeout(function(){slider_intro()}, 6000); //select change time
			}
		}
		setTimeout(function(){slider_intro()}, 6000)
	  //===============
		
		jQuery('#left_but').hover(
		   function () {
			 jQuery(this).addClass("over");
		   },
		   function () {
			 jQuery(this).removeClass("over");
		   })
		
		jQuery('#right_but').hover(
		   function () {
			 jQuery(this).addClass("over");
		   },
		   function () {
			 jQuery(this).removeClass("over");
		   })
		
		jQuery('.cms-home .products-grid li').hover(
		   function () {
			 jQuery(this).find('.product-name').stop(true, true).slideDown("slow");
		   },
		   function () {
			 jQuery(this).find('.product-name').hide("slow");
		   })
    }
    
</script>
	
</body>
</html>
